package javatunes;

public class mhod {
	
	int type=0;
	int headerlength=0;
	int totallength=0;
	
	int positionofstring=0;
	int lengthofstring=0;
	String str="";
	
	/** 
	 * 0   4 -mhod 
	 * 4   4 -header length			--> start here (header already read)
	 * 8   4 -total length
	 * 12  4 -type indicator (1-14 is strings)
	 ... -> dependant on type
	 */ 
	
	
	/** 
	 * String type:
	 * 0   4 -mhod 
	 * 4   4 -header length			--> start here (header already read)
	 * 8   4 -total length
	 * 12  4 -type indicator (1-14 is strings)
	 * 16  4 -...
	 * 20  4 -...
	 * 24  4 -position    --> String start
	 * 28  4 -lengthofstring
	 * 32  4 -...
	 * 36  4 -...
	 * 40  l - string
	 */ 
	public mhod (sebpac p) {
		headerlength=p.g4i();
		totallength=p.g4i();
		lengthofstring=totallength-headerlength-16; // not sure why...
		type=p.g4i();
		// have read 12 bytes, plus 4 bytes for mhod identifier
		// at index 16
		if (type>0 && type<15) {
			
			p.pos+=24; // skip 6 randoms
			str=p.gnstrdata(lengthofstring);
		}
		else {
			// skip past mhod item...
			p.pos+=totallength-16;
		}
	}
	
	public String toString() {
		return "type: " + type +", str: " + str;
	}
}
